# Author    :Dun_Hz
# Time      :2024/3/13 19:28
# 熄灯问题，按下按钮后，周围的灯状态也要改变
#

import numpy as np
# line = [[0] *6]*5
# print(line)
# for i in range(5):
#     line[i]=input("请输入第"+str(i+1)+"行：").split(',')
#     line[i]= list(map(int,line[i]))
line = [
    [0,0,0,1,1,1],
    [0,1,0,0,1,0],
    [1,1,1,0,0,0],
    [1,0,1,1,0,1],
    [0,0,0,1,0,1]
]
print(type(line))       #列表
      #列表
puzzle = np.array(line)     #np数组
zero = np.zeros(6)
#插入
puzzle = np.insert(puzzle, 0, values = zero, axis=0)
puzzle = np.insert(puzzle, 6, values = zero, axis=1)
puzzle = np.insert(puzzle, 0, values = zero, axis=1)
print(puzzle)

press = np.zeros(puzzle.shape)
# b = [[0 for col in range(8)] for row in range(6)]
# press = np.array(b)
# print(press)
def guess():
    for r in range(1, puzzle.shape[0]-1): #
        for c in range(1,puzzle.shape[1]-1):
            # 假如该灯亮着，它下一行
            press[r+1][c] = (puzzle[r][c]+
                             press[r][c]+press[r-1][c]+press[r][c-1]+press[r][c+1]) % 2
    for c in range(1,7):
            if (press[5][c-1]+press[5][c]+press[5][c+1]+press[4][c])%2 != puzzle[5][c]:
                return False
    return 1
def enumeration():
    while guess()==0:
        press[1][1]+=1
        c = 1
        while (press[1][c]>1):
            press[1][c]=0
            c+=1
            press[1][c]+=1
        continue
enumeration()